import 'ly_comment_model.dart';

class LyVideoModel {
  LyVideoModel({
    this.userId,
    this.nickname,
    this.avatar,
    this.title,
    this.cover,
    this.videoPath,
    this.isGreat,
    this.isFollow,
    this.comments,
  });

  LyVideoModel.fromJson(dynamic json) {
    userId = json['userId'];
    nickname = json['nickname'];
    avatar = json['avatar'];
    title = json['title'];
    cover = json['cover'];
    videoPath = json['videoPath'];
    isGreat = json['isGreat'];
    isFollow = json['isFollow'];
    id = json['id'];
    isBlack = json['isBlack'];
    mediaUrl = json['mediaUrl'];
    middleThumbUrl = json['middleThumbUrl'];
    if (json['comments'] != null) {
      comments = [];
      json['comments'].forEach((v) {
        comments?.add(LYCommentModel.fromJson(v));
      });
    }
  }
  String? userId;
  String? nickname;
  String? avatar;
  String? title;
  String? cover;
  String? videoPath;
  bool? isGreat;
  bool? isFollow;
  String? id;
  bool? isBlack;
  String? mediaUrl;
  String? middleThumbUrl;
  List<LYCommentModel>? comments;
  LyVideoModel copyWith({
    String? userId,
    String? nickname,
    String? avatar,
    String? title,
    String? cover,
    String? videoPath,
    bool? isGreat,
    bool? isFollow,
    List<LYCommentModel>? comments,
  }) =>
      LyVideoModel(
        userId: userId ?? this.userId,
        nickname: nickname ?? this.nickname,
        avatar: avatar ?? this.avatar,
        title: title ?? this.title,
        cover: cover ?? this.cover,
        videoPath: videoPath ?? this.videoPath,
        isGreat: isGreat ?? this.isGreat,
        isFollow: isFollow ?? this.isFollow,
        comments: comments ?? this.comments,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['userId'] = userId;
    map['nickname'] = nickname;
    map['avatar'] = avatar;
    map['title'] = title;
    map['cover'] = cover;
    map['videoPath'] = videoPath;
    map['isGreat'] = isGreat;
    map['isFollow'] = isFollow;
    map['id'] = id;
    map['isBlack'] = isBlack;
    map['middleThumbUrl'] = middleThumbUrl;
    map['mediaUrl'] = mediaUrl;
    if (comments != null) {
      map['comments'] = comments?.map((v) => v.toJson()).toList();
    }
    return map;
  }
}
